#pragma once

#include <d3dx10.h>
#include <list>
#include <vector>
#include "MeshSubset.h"
#include "EngineObject.h"
#include "EnginePointer.h"
#include "ModelVertexBuffer.h"
#include "ModelIndexBuffer.h"
#include "EnginePointer.h"

using namespace std;

#define MAX_MESH_NAME 100
#define MAX_VERTEX_STREAMS 16

class ModelMesh : public EngineObject
{
public:
	ModelMesh(char* name, BYTE numVertexBuffers, vector<EnginePointer<ModelVertexBuffer>>* vertexBuffers,
		      UINT* vertexBufferIndexes, EnginePointer<ModelIndexBuffer>& indexBuffer,
			  D3DXVECTOR3 boundingBoxCenter, D3DXVECTOR3 boundingBoxExtents,
			  UINT numSubsets, vector<EnginePointer<MeshSubset>>* subsets, UINT* subsetIndexes);

	HRESULT LoadGraphicsContent(EnginePointer<ID3D10Device> pDevice);
	void UnloadGraphicsContent();
	ID3D10Buffer** getVertexBuffers();
	BYTE getNumVertexBuffers();
	UINT* getStrides();
	EnginePointer<ID3D10Buffer> getIndexBuffer();
	list<EnginePointer<MeshSubset>>::iterator subsetBegin();
	list<EnginePointer<MeshSubset>>::iterator subsetEnd();
	AUTO_SIZE;
private:
	char name[MAX_MESH_NAME];
    BYTE numVertexBuffers;
	UINT strides[MAX_VERTEX_STREAMS];
    EnginePointer<ModelVertexBuffer> vertexBuffers[MAX_VERTEX_STREAMS];
    EnginePointer<ModelIndexBuffer> indexBuffer;

	ID3D10Buffer* d3dVertexBuffers[MAX_VERTEX_STREAMS];
    D3DXVECTOR3 boundingBoxCenter;
    D3DXVECTOR3 boundingBoxExtents;

	list<EnginePointer<MeshSubset>> subsets;
};
